home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
.net 2002 March
/
DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin
/
pc
/
PC Software
/
free_browsing
/
DavesQckSearchDbar3-14
/
dqsd.exe
/
searches
/
hexconv.xml
< prev
next >
Wrap
Text File
|
2002-08-30
|
2KB
|
63 lines
<search function="hexconv">
<name>Base Conversion: Hexadecimal</name>
<description>
Convert hexadecimal values to decimal, octal and binary equivalents.<br/>
<div class="helpboxDescLabels">Example:</div>
<table class="helpboxDescTable">
<tr><td>hexconv 3A</td></tr>
</table>
</description>
<category>Functions</category>
<contributor>Monty Scroggins</contributor>
<script><![CDATA[
function decfromhex(num)
{
while (num.length < 4)
num = "0" + num;
return (eval(getnum(num.substring(3,4))) + eval(getnum(num.substring(2,3))) * 16 +eval(getnum(num.substring(1,2))) * 256 + eval(getnum(num.substring(0,1))) * 4096);
}
function getnum(letter)
{
if (letter <= "9")
return letter;
else
{
if ((letter == "a") || (letter == "A"))
return 10;
if ((letter == "b") || (letter == "B"))
return 11;
if ((letter == "c") || (letter == "C"))
return 12;
if ((letter == "d") || (letter == "D"))
return 13;
if ((letter == "e") || (letter == "E"))
return 14;
if ((letter == "f") || (letter == "F"))
return 15;
return 0;
}
}
function hexconv(c)
{
if( nullArgs("hexconv",c) )
return false;
var dec = decfromhex(c);
var int = parseInt(dec);
document.deff.q.value = "hex: "+c+
" dec: "+int.toString(10)+
" oct: "+int.toString(8)+
" bin: "+int.toString(2);
}
]]></script>
<copyright>
Copyright (c) 2002 David Bau
Distributed under the terms of the
GNU Public License, Version 2 (http://www.gnu.org/copyleft/gpl.txt)
</copyright>
</search>